<?php
namespace Nawa\MedicalStudy\MedicalCenter\Monitoring;
/**
 * Medical Center (of a Medical Study) Partners.
 *
 * It represant a Patient of the medical center or a customer
 *
 * @author Xavier VILAIN
 * @package Nawa\MedicalStudy\MedicalCenter
 *
 * @property int	$msid			Id of the MS
 * @property int	$mcid			Id of the MC
 * @property int 	$customerid 	Id of Customer Partner
 * @property string $role 			Partner Role
 * @property datetime $udate 		Last Change
 * @property int $uname 			last author
 */
class Partner extends \Fox\Object {

	/**
	 * Link to Medical Study
	 */
	const LINK_MEDICAL_STUDY = 'medicalStudy';

	/**
	 * Link to Medical Center
	 */
	const LINK_MEDICAL_CENTER = 'medicalCenter';

	/**
	 * Link to Medical Center
	 */
	const LINK_MEDICAL_CENTER_PARTNER = 'medicalCenterPartner';

	/**
	 * Link to Medical Center Monitoring
	 */
	const LINK_MEDICAL_CENTER_MONITORING = 'monitoring';
	
	/**
	 *
	 * Link to Customer
	 * @var string
	 */
	const LINK_CUSTOMER = 'customer';

	/**
	 * Standard Role
	 */
	const ROLE_STANDARD = 'cust';

	/**
	 *
	 * Get id of the partner according to the parnter type
	 */
	public function partnerid() {
		return $this->customerid;
	}

	/**
	 * Corresponding Partner object (not the link)
	 * @return \Nawa\Customer
	 */
	public function partner() {
		try {
			$partner = \Fox\Dao::load(\Nawa\Customer::className(),$this->customerid);
		} catch(\Fox\Object\Exception\NotExist $e) {
			// Should not be possible
			$partner = new \Nawa\Customer();
		}
		return $partner;
	}

}
\Fox\Dao::infos(Partner::className(),new \Fox\Object\Info('ms_mc_monitoring_partners', \Fox\Databases::DB_APP));

\Nawa\Customer::className();